<template>
    <section>
        <el-dialog title="赠送优惠券" :visible.sync="dialogVisible">
            <elTable ref="t" :formData="formData" @tableData="getList">
                <el-table-column v-for="item in tableField"
                    :prop="item.prop"
                    :label="item.label"
                    align="center"
                    :show-overflow-tooltip="true"
                    :formatter="item.formatter"
                >
                </el-table-column>
                <el-table-column label="操作" align="center" width="200">
                    <template slot-scope="{row}">
                        <el-button type="primary" size="mini" @click.native="give(row)">赠送</el-button>
                    </template>
                </el-table-column>
            </elTable>
        </el-dialog>
    </section>
</template>

<script>
    import apisAccount from '@/api/accounts/accountLibrary' //api
    import elTable from "@/components/xForm/elTable"
    export default {
        name: 'dialogCoupon',
        data() {
            return {
                dialogTitle: '',
                dialogVisible: false,
                formData: {
                    id: '',
                    currentPage: 1,
                    pageSize: 10
                },
                tableField: [
                    {label: '优惠券名称', prop: 'name'},
                    {label: '面额', prop: 'money'},
                    {label: '满多少金额可用', prop: 'money'},
                    {label: '券有效期', prop: 'time', formatter:(row, column, cellValue, index)=>{
                        return row.time
                    }},
                    {label: '状态', prop: 'status', formatter:(row, column, cellValue, index)=>{
                        return row.status
                    }},
                    {label: '是否领取', prop: 'status', formatter:(row, column, cellValue, index)=>{
                        return row.status
                    }},
                ]
            }
        },
        components: {elTable},
        methods: {
            open(row) {
                this.dialogVisible = true
                this.formData.id = row.id
            },
            getList(pageNo) {
                let that = this
                this.formData.currentPage = pageNo || this.formData.currentPage
                let dataInfo = [{
                    id: 1,
                    name: '优惠券1',
                    money: 20,
                    time: '2020-10-2',
                    status: '已使用',
                }]
                let total = 13
                this.$nextTick(()=>{
                    this.$refs.t.loadData(dataInfo, total)
                })
            },
            /*赠送优惠券*/
            give(row) {
            
            }
        }
    }
</script>

<style scoped>

</style>
